<?php

namespace App\Http\Resources;

use App\Models\Configuration;
use App\Models\Salesman;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/** @mixin Salesman */
class SalesmanResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  Request  $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            //'admin_user_id' => $this->admin_user_id,
            'contact' => $this->contact,
            'icon' => sprintf('%s/%s', aliyun_domain(), Salesman::ICON_MAP[$this->type]),
            'platform' => $this->type,
            'url' => $this->url ?? '',
            'group_link' => Configuration::getItem('GroupLink'),
        ];
    }
}
